package com.yinxin.time;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * @author yinxin
 * @version 1.0
 * @Description:
 * @date 2022/10/2614:58
 */
public class LocalDateTimeTets {
   public static void main(String[] args) {
      LocalDateTime now1 = LocalDateTime.now();
      System.out.println(now1);
      LocalDateTime now2 = LocalDateTime.now(ZoneId.of("America/Los_Angeles"));
      System.out.println(now2);
      LocalDateTime now3 = LocalDateTime.now(ZoneId.of("Asia/Shanghai"));
      System.out.println(now3);
      //Date转String
      Date date = new Date();
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      String dateStr = sdf.format(date);
      System.out.println(dateStr);
   }
}
